import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { ElNotification } from "element-plus"; //处理导航信息
import { WorkOrder } from "@/api/backend/index";
import { mapCompanies } from "@/utils/common";
import { log } from "console";

export const useWorkOrder = defineStore(Names.WorkOrder, {
  state: () => {
    return {
      single: {
        createBy: null,
        createTime: "",
        customerId: 0,
        customerName: "",
        customerPhone: "",
        deviceAddress: "",
        deviceCode: "",
        employeeId: null,
        employeeName: null,
        endTime: null,
        finishPhoto: null,
        id: 1,
        projectName: "",
        remark: null,
        startTime: null,
        status: "1",
        updateBy: null,
        updateTime: null,
        chargePerson: "",
        processPhoto: [],
        downTime: "",
        coordinate: "",
        faults: [],
        description: "",
        projectId: "",
        gatewayCode: "",
        deviceName: "",
        picture: [],
      },
      topNewsNum: 0, //系统消息盒子（暂时关于未审核工单）
      topNewsObj: <any>[], //系统消息盒子列表
    };
  },
  getters: {},
  actions: {
    //获取工单单个/列表数据
    getSingleAndListOrderAuto(filter: any) {
      return new Promise((resolve, reject) => {
        _get(WorkOrder + "/list", filter, "json", "").then((res) => {
          console.log("获取工单单个/列表数据", res);
          resolve(res);
        });
      });
    },
    //修改工单数据
    changWorkOrder(data: any) {
      return new Promise((resolve, reject) => {
        _put(WorkOrder, data, "json", "").then((res) => {
          console.log("修改工单数据", res);
          resolve(res);
        });
      });
    },
  },
});
